<!DOCTYPE html>
<html>

<head>
    <base href="{#location.origin#}/res/smartadmin-402/" />
    <meta charset="utf-8">
    <title>
        首页 - Uim部署控制台 v1.0
    </title>
    <meta name="description" content="系统后台前端框架首页">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, minimal-ui">
    <!-- Call App Mode on ios devices -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- Remove Tap Highlight on Windows Phone IE -->
    <meta name="msapplication-tap-highlight" content="no">
    <!-- base css -->
    <link rel="stylesheet" media="screen, print" href="css/vendors.bundle.css">
    <link rel="stylesheet" media="screen, print" href="css/app.bundle.css">
    <link rel="stylesheet" media="screen, print" href="css/notifications/toastr/toastr.css">

    <style>
        .page-logo img {
            width: 28px;
            height: 28px;
        }

        .text-truncate-sm {
            max-width: 137px;
        }

        /* html,
        body {
            margin: 0px 0px;
            width: 100%;
            height: 100%;
            overflow: hidden;
        } */
        /* .page-content {
            padding: 0 !important;
        } */

        .page-content .panel-content {
            padding: 0 !important;
        }

        iframe {
            margin: 0px 0px;
            width: 100%;
            /* height: 100%; */
            border: none;
            /* position: absolute; */
        }

        .page-footer {
            border-top: solid 1px #ccc;
        }

        .nav-menu li>ul li a {
            color: #aa99c4;
            padding: .8125rem 2rem .8125rem 5rem;
        }

        .nav-menu li>ul li>ul li a {
            color: #aa99c4;
            padding: .8125rem 2rem .8125rem 6rem;
        }

        .nav-menu li>ul li>ul li>ul li a {
            color: #aa99c4;
            padding: .8125rem 2rem .8125rem 7rem;
        }

        .nav-menu li>ul li>ul li>ul li>ul li a {
            color: #aa99c4;
            padding: .8125rem 2rem .8125rem 8rem;
        }

        .info-card img.cover {
            height: 155px;
        }

        @media (min-width: 992px) {

            .nav-function-hidden:not(.nav-function-top) .page-sidebar:after {
                content: "";
                background: 0 0;
                height: 100%;
                display: block;
                position: fixed;
                z-index: 1;
                top: 0;
                bottom: 0;
                left: 0;
                width: 2.1rem;
            }
        }
    </style>
</head>

<body class="mod-bg-1 ">
    {#include template="include/page-settings"/#}
    <!-- BEGIN Page Wrapper -->
    <div class="page-wrapper">
        <div class="page-inner">
            <!-- BEGIN Left Aside -->
            <aside class="page-sidebar">
                <div class="page-logo">
                    <a href="javascript:void(0);"
                        class="page-logo-link press-scale-down d-flex align-items-center position-relative"
                        data-toggle="modal" data-target="#modal-shortcut">
                        <img src="img/logo.png" alt="{#uim.config.app_name#}" aria-roledescription="logo">
                        <span class="page-logo-text mr-1">{#uim.config.app_name#}</span>
                        <span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
                        <i class="fal fa-angle-down d-inline-block ml-1 fs-lg color-primary-300"></i>
                    </a>
                </div>
                <!-- BEGIN PRIMARY NAVIGATION -->
                <nav id="js-primary-nav" class="primary-nav" role="navigation">
                    <div class="nav-filter">
                        <div class="position-relative">
                            <input type="text" id="nav_filter_input" placeholder="筛选菜单" class=" form-control"
                                tabindex="0">
                            <a href="javascript:void(0);" onclick="return false;"
                                class="btn-primary btn-search-close js-waves-off" data-action="toggle"
                                data-class="list-filter-active" data-target=".page-sidebar">
                                <i class="fal fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="info-card">
                        <img src="{#uim.session.head_portrait#}" class="profile-image rounded-circle"
                            alt="{#uim.session.real_name#}">
                        <div class="info-card-text">
                            <a href="javascript:void(0);" class="d-flex align-items-center text-white">
                                <span class="text-truncate text-truncate-sm d-inline-block">
                                    {#uim.session.real_name#}
                                </span>
                            </a>
                            <span class="d-inline-block text-truncate text-truncate-sm">{#uim.say_time()#}</span>
                        </div>
                        <img src="img/card-backgrounds/cover-1-lg.png" class="cover" alt="cover">
                        <a href="javascript:void(0);" onclick="return false;" class="pull-trigger-btn"
                            data-action="toggle" data-class="list-filter-active" data-target=".page-sidebar"
                            data-focus="nav_filter_input">
                            <i class="fal fa-angle-down"></i>
                        </a>
                    </div>
                    {#include template="include/left-menu"/#}
                    <div class="filter-message js-filter-message bg-success-600"></div>
                </nav>
                <!-- END PRIMARY NAVIGATION -->
                <!-- NAV FOOTER -->
                <div class="nav-footer shadow-top">
                    <a href="javascript:void(0);" onclick="return false;" data-action="toggle"
                        data-class="nav-function-minify" class="hidden-md-down">
                        <i class="ni ni-chevron-right"></i>
                        <i class="ni ni-chevron-right"></i>
                    </a>
                    <ul class="list-table m-auto nav-footer-buttons">
                        <li>
                            <a href="javascript:void(0);" data-toggle="tooltip" data-placement="top" title="在线反馈">
                                <i class="fal fa-comments"></i>
                            </a>
                        </li>
                        <li>
                            <a href="javascript:void(0);" data-toggle="tooltip" data-placement="top" title="使用帮助">
                                <i class="fal fa-life-ring"></i>
                            </a>
                        </li>
                        <li>
                            <a href="javascript:void(0);" data-toggle="tooltip" data-placement="top" title="电话支持">
                                <i class="fal fa-phone"></i>
                            </a>
                        </li>
                    </ul>
                </div>
                <!-- END NAV FOOTER -->
            </aside>
            <!-- END Left Aside -->
            <div class="page-content-wrapper">
                <!-- BEGIN Page Header -->
                <header class="page-header" role="banner">
                    <!-- we need this logo when user switches to nav-function-top -->
                    <div class="page-logo">
                        <a href="javascript:void(0);"
                            class="page-logo-link press-scale-down d-flex align-items-center position-relative"
                            data-toggle="modal" data-target="#modal-shortcut">
                            <img src="img/logo.png" alt="{#uim.config.app_name#}" aria-roledescription="logo">
                            <span class="page-logo-text mr-1">{#uim.config.app_name#}</span>
                            <span
                                class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
                            <i class="fal fa-angle-down d-inline-block ml-1 fs-lg color-primary-300"></i>
                        </a>
                    </div>
                    <!-- DOC: nav menu layout change shortcut -->
                    <div class="hidden-md-down dropdown-icon-menu position-relative">
                        <a href="javascript:void(0);" class="header-btn btn js-waves-off" data-action="toggle"
                            data-class="nav-function-hidden" title="Hide Navigation">
                            <i class="ni ni-menu"></i>
                        </a>
                        <ul>
                            <li>
                                <a href="javascript:void(0);" class="btn js-waves-off" data-action="toggle"
                                    data-class="nav-function-minify" title="Minify Navigation">
                                    <i class="ni ni-minify-nav"></i>
                                </a>
                            </li>
                            <li>
                                <a href="javascript:void(0);" class="btn js-waves-off" data-action="toggle"
                                    data-class="nav-function-fixed" title="Lock Navigation">
                                    <i class="ni ni-lock-nav"></i>
                                </a>
                            </li>
                        </ul>
                    </div>
                    <!-- DOC: mobile button appears during mobile width -->
                    <div class="hidden-lg-up">
                        <a href="javascript:void(0);" class="header-btn btn press-scale-down" data-action="toggle"
                            data-class="mobile-nav-on">
                            <i class="ni ni-menu"></i>
                        </a>
                    </div>
                    <div class="ml-auto d-flex">
                        <!-- app settings -->
                        <div class="hidden-md-down">
                            <a href="javascript:void(0);" class="header-icon" data-toggle="modal"
                                data-target=".js-modal-settings">
                                <i class="fal fa-cog"></i>
                            </a>
                        </div>
                        <!-- app user menu -->
                        <div>
                            <a href="javascript:void(0);" data-toggle="dropdown" <!--
                                class="header-icon d-flex align-items-center justify-content-center ml-2">
                                <img src="{#uim.session.head_portrait#}" class="profile-image rounded-circle"
                                    alt="{#uim.session.real_name#}">
                                <!-- you can also add username next to the avatar with the codes below:
									<span class="ml-1 mr-1 text-truncate text-truncate-header hidden-xs-down">Me</span>
									<i class="ni ni-chevron-down hidden-xs-down"></i> -->
                            </a>
                            <div class="dropdown-menu dropdown-menu-animated dropdown-lg">
                                <div class="dropdown-header bg-trans-gradient d-flex flex-row py-4 rounded-top">
                                    <div class="d-flex flex-row align-items-center mt-1 mb-1 color-white">
                                        <span class="mr-2">
                                            <img src="{#uim.session.head_portrait#}"
                                                class="rounded-circle profile-image" alt="{#uim.session.real_name#}">
                                        </span>
                                        <div class="info-card-text">
                                            <div class="fs-lg text-truncate text-truncate-lg">
                                                {#uim.session.real_name#}</div>
                                            <span
                                                class="text-truncate text-truncate-md opacity-80">{#uim.say_time()#}</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="dropdown-divider m-0"></div>
                                <a href="javascript:void(0);" class="dropdown-item" data-toggle="modal"
                                    data-target="#updatePwdModal">
                                    <span data-i18n="drpdwn.settings">修改密码</span>
                                </a>
                                <div class="dropdown-divider m-0"></div>
                                <a href="javascript:void(0);" class="dropdown-item" data-action="app-fullscreen">
                                    <span data-i18n="drpdwn.fullscreen">全屏</span>
                                    <i class="float-right text-muted fw-n">F11</i>
                                </a>
                                <div class="dropdown-divider m-0"></div>
                                <a class="dropdown-item fw-500 pt-3 pb-3 a-logout" href="javascript:void(0);">
                                    <span data-i18n="drpdwn.page-logout">注销登录</span>
                                </a>
                            </div>
                        </div>
                    </div>
                </header>
                <!-- END Page Header -->
                <!-- BEGIN Page Content -->
                <!-- the #js-page-content id is needed for some plugins to initialize -->
                <main id="js-page-content" role="main" class="page-content">
                    <div class="row">
                    </div>
                </main>
                <script type="text/html" id="tpl-new-panel">
                    <div class="col-xl-6">
                        <div class="panel">
                            <div class="panel-hdr">
                                <h2></h2>
                                <div class="panel-toolbar">
                                    <button class="btn btn-panel" data-action="panel-collapse" data-toggle="tooltip"
                                        data-offset="0,10" data-original-title="收起/展开"></button>
                                    <button class="btn btn-panel" data-action="panel-fullscreen" data-toggle="tooltip"
                                        data-offset="0,10" data-original-title="全屏/取消全屏"></button>
                                    <button class="btn btn-panel" data-action="panel-close" data-toggle="tooltip"
                                        data-offset="0,10" data-original-title="关闭"></button>
                                </div>
                            </div>
                            <div class="panel-container show">
                                <div class="panel-content">
                                    <iframe onload="setIframeHeight(this)"></iframe>
                                </div>
                            </div>
                        </div>
                    </div>
                </script>
                <!-- this overlay is activated only when mobile menu is triggered -->
                <div class="page-content-overlay" data-action="toggle" data-class="mobile-nav-on"></div>
                <!-- END Page Content -->
                {#include template="include/page-footer"/#}
                <!-- LOST END Shortcuts -->
                {#include template="include/color-profile"/#}
            </div>
        </div>
    </div>
    <!-- END Page Wrapper -->
    <!-- BEGIN 修改密码 -->
    <div class="modal fade" id="updatePwdModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-lgg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">修改密码</h5>
                    <button type="button" class="bootbox-close-button close" aria-hidden="true" data-dismiss="modal"
                        aria-label="Close"><i class="fal fa-times"></i></button>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" id="audit_form">
                        <div class="form-group student-name">
                            <label class="form-label" for="nickname">请输入原密码</label>
                            <input type="password" id="old-password" class="form-control">
                        </div>
                        <div class="form-group student-name">
                            <label class="form-label" for="nickname">设置新密码</label>
                            <input type="password" id="new-password" class="form-control">
                        </div>
                        <div class="form-group student-name">
                            <label class="form-label" for="nickname">确认新密码</label>
                            <input type="password" id="new-password2" class="form-control">
                        </div>
                    </form>
                </div>
                <div class="modal-footer"><button type="button" class="btn btn-success update-pwd-btn">确定</button></div>
            </div>
        </div>
    </div>
    <!-- END 审核 -->
    <!-- LOST END Quick Menu -->
    <!-- LOST END Messenger -->
    <script src="js/vendors.bundle.js"></script>
    <script src="js/app.bundle.js"></script>
    <script src="js/notifications/toastr/toastr.js"></script>

    <script>
        // document.getElementsByTagName('iframe')[0].onload = function () {
        //     try {
        //         if (frames[0].location.protocol !== 'blob:' && frames[0].location.href != 'about:blank') {
        //             return alert('开发提示：请使用模板渲染，勿进行链接跳转！\n当前跳转地址：' + frames[0].location.href)
        //         }
        //         top.document.title = frames[0].document.title;
        //         var view_path = top.location.hash.split('#')[1];
        //         var left_menu = $('#js-nav-menu a[data-view="' + view_path + '"]');
        //         if (left_menu.length) {
        //             $('#js-nav-menu .active').each(function () {
        //                 if (!$(this).hasClass('open')) $(this).removeClass('active')
        //             })
        //             $(left_menu).parents('li').addClass('active');
        //         }
        //     } catch (error) {
        //         top.document.title = '您已跨域' + document.getElementsByTagName('iframe')[0].src
        //     }

        // };

        // $('#js-page-content').smartPanel({
        //     // localStorage: true,
        //     onChange: function () { },
        //     onSave: function () { },
        //     opacity: 1,
        //     deleteSettingsKey: '#deletesettingskey-options',
        //     settingsKeyLabel: 'Reset settings?',
        //     deletePositionKey: '#deletepositionkey-options',
        //     positionKeyLabel: 'Reset position?',
        //     sortable: true,
        //     buttonOrder: '%collapse% %fullscreen% %close%',
        //     buttonOrderDropdown: '%refresh% %locked% %color% %custom% %reset%',
        //     customButton: true,
        //     customButtonLabel: "自定义按钮",
        //     onCustom: function () { },
        //     closeButton: true,
        //     onClosepanel: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onClosepanel")
        //     },
        //     fullscreenButton: true,
        //     onFullscreen: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onFullscreen")
        //     },
        //     collapseButton: true,
        //     onCollapse: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onCollapse")
        //     },
        //     lockedButton: true,
        //     lockedButtonLabel: "锁定",
        //     onLocked: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onLocked")
        //     },
        //     refreshButton: true,
        //     refreshButtonLabel: "刷新",
        //     onRefresh: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onRefresh")
        //     },
        //     colorButton: true,
        //     colorButtonLabel: "样式",
        //     onColor: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onColor")
        //     },
        //     panelColors: ['bg-primary-700 bg-success-gradient',
        //         'bg-primary-500 bg-info-gradient',
        //         'bg-primary-600 bg-primary-gradient',
        //         'bg-info-600 bg-primray-gradient',
        //         'bg-info-600 bg-info-gradient',
        //         'bg-info-700 bg-success-gradient',
        //         'bg-success-900 bg-info-gradient',
        //         'bg-success-700 bg-primary-gradient',
        //         'bg-success-600 bg-success-gradient',
        //         'bg-danger-900 bg-info-gradient',
        //         'bg-fusion-400 bg-fusion-gradient',
        //         'bg-faded'],
        //     resetButton: true,
        //     resetButtonLabel: "重置",
        //     onReset: function () {
        //         if (myapp_config.debugState)
        //             console.log($(this).closest(".panel").attr('id') + " onReset callback")
        //     }
        // });
        function updateIframeHeight(view_name) {
            console.log('设置高度：' + view_name)
            let iframe = document.getElementById('iframe:' + view_name);
            setIframeHeight(iframe)
        }
        function setIframeHeight(iframe) {
            if (iframe) {
                var iframeWin = iframe.contentWindow //|| iframe.contentDocument.parentWindow;
                if (iframeWin.document.body) {
                    iframeWin.ignore_resize = true;
                    iframe.height = 0;
                    iframe.height = 10 + (iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight);
                    console.log('设置高度成功：' + iframe.height);
                    setTimeout(function () {
                        iframeWin.ignore_resize = false;
                    }, 500);
                }
            }
        }

        function get_panel_iframe(view_name, title) {
            let has_iframe = $('main .row .panel[view-name="' + view_name + '"]');
            if (has_iframe.length) {
                console.log('已经存在')
                return has_iframe.find('iframe')[0].contentWindow;
            } else {
                console.log('新建iframe')
                let new_row = $($('#tpl-new-panel').html());
                new_row.find('h2').html(title);
                new_row.find('.panel').attr('view-name', view_name);
                new_row.find('iframe').attr('id', 'iframe:' + view_name);
                new_row.find('.btn-panel').tooltip();
                $('main .row').prepend(new_row);
                return $('main .row').find('iframe')[0].contentWindow;
            }
        }
        $('#js-nav-menu a').click(function () {
            var that = this;
            // 如果后面还有ul，则说明属于父级菜单
            if ($(that).next().length) return;

            var view = $(that).data('view'); // todo tothink 视图是一定要按照power的节点路径来放还是在扩展数据中配置？扩展中过于灵活不受规范约束，power路径要求死板（简单好记），暂选后者
            uim.view(view, { data: {} }, get_panel_iframe(view, $(that).attr('title')), function () {

                $('#js-nav-menu .active').each(function () {
                    if (!$(this).hasClass('open')) $(this).removeClass('active');
                })
                $(that).parents('li').addClass('active');
            }, function (err) {

                toastr.error('打开视图出错')
                initApp.playSound('media/sound', 'messagebox')

                bootbox.alert({
                    title: "<i class='fal fa-times-circle text-danger mr-2'></i> 打开视图出错",
                    message: "<span><strong>提示：</strong> 请联系系统管理员，或稍后重试</span>",
                    centerVertical: true,
                    swapButtonOrder: true,
                    buttons: {
                        ok: {
                            label: '确定',
                            className: 'btn-danger shadow-0'
                        },
                    },
                    className: "modal-alert",
                    closeButton: false,
                    callback: function () {
                        // console.log('');
                    }
                });
            })


        })

        $('.a-logout').click(function () {
            uim.session_clear(function () {
                parent.location.reload();
                return;
                if (uim.config.sso_host) {
                    top.location = uim.config.sso_host + '?' + uim.init_param.deploy_app_id;
                } else {
                    uim.view('login');
                }
            });
        })
        if (uim.session.expiry_time < uim.dateTime()) {
            uim.view('screen-locked');
        } else {
            let default_view = 'page/dashboard';
            uim.view(default_view, {}, get_panel_iframe(default_view, '主面板'));
        }

        $('.update-pwd-btn').click(function () {
            var old_password = $('#old-password').val();
            if (!old_password) {
                return bootbox.alert('请输入原密码！', function () {
                    $('#old-password').focus();
                });
            }
            var new_password = $('#new-password').val();
            if (!new_password) {
                return bootbox.alert('请输入新密码！', function () {
                    $('#new-password').focus();
                });
            }
            var new_password2 = $('#new-password2').val();
            if (new_password != new_password2) {
                return bootbox.alert('两次密码输入不一致！', function () {
                    $('#new-password2').focus();
                });
            }
            uim.api.emit({
                code: 'user.account.loginPassword.update',
                data: {
                    old_login_password: uim.MD5('login_password_' + old_password),
                    login_password: uim.MD5('login_password_' + new_password),
                },
                success: function (data) {
                    toastr.success('操作成功')
                    $('#updatePwdModal').modal('hide').find('input').val('');
                }
            })
        });


        uim.set_error_handle({
            // window_error: function (msg, url, line, col, error) { },
            api_error: function (api_code, back_data) {
                console.log('统一处理接口返回错误信息', { api_code, back_data });
                bootbox.alert(back_data.text);
            },
            // api_fail: function (req, fail, back_data) { }, // 可用于重试请求和切换接口请求方式
        });
    </script>
</body>

</html>